////////////////////////////////////////////////////////////////////////////////////////////////////
/// Copyright (c) 2009 - 2010 RacoonStudios
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this
/// software and associated documentation files (the "Software"), to deal in the Software
/// without restriction, including without limitation the rights to use, copy, modify, merge,
/// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
/// to whom the Software is furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all copies or
/// substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
/// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
/// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
/// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/// DEALINGS IN THE SOFTWARE.
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once
#ifndef rectangle_h__
#define rectangle_h__

#include "core/types.h"

namespace Math
{
	////////////////////////////////////////////////////////////////////////////////////////////////////
	///	\class	rectangle
	///
	///	\brief	A template rectangle class.
	///
	///	\date	2010/03/05
	///	\author	khaos                                                            
	////////////////////////////////////////////////////////////////////////////////////////////////////
	template<class T>
	class rectangle
	{
		public:

			////////////////////////////////////////////////////////////////////////////////////////////////////
			///	\fn		rectangle()
			///			
			///	\brief	Default constructor. 
			///
			///	\date	2010/03/05
			///	\author	khaos  
			////////////////////////////////////////////////////////////////////////////////////////////////////
			rectangle();

			////////////////////////////////////////////////////////////////////////////////////////////////////
			/// \fn	rectangle(T l, T t, T r, T b)
			///
			/// \brief	Constructor. 
			///
			/// \author	khaos
			/// \date	09.12.2009
			///
			/// \param	[in]	l	The left element.
			/// \param	[in]	t	The top element.
			/// \param	[in]	r	The right element.
			/// \param	[in]	b	The bottom element.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			rectangle(T l, T t, T r, T b);




			////////////////////////////////////////////////////////////////////////////////////////////////////
			/// \fn	void set(T l, T t, T r, T b)
			///
			/// \brief	Sets the corner's of the rectangle.
			///
			/// \author	khaos
			/// \date	09.12.2009
			///
			/// \param	[in]	l	The left element.
			/// \param	[in]	t	The top element.
			/// \param	[in]	r	The right element.
			/// \param	[in]	b	The bottom element.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			void set(T l, T t, T r, T b);

			////////////////////////////////////////////////////////////////////////////////////////////////////
			/// \fn	T width() const
			///
			/// \brief	Returns the width of the rectangle.
			///
			/// \author	khaos
			/// \date	09.12.2009
			///
			/// \return	The rectangles width.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			T width() const;

			////////////////////////////////////////////////////////////////////////////////////////////////////
			/// \fn	T height() const
			///
			/// \brief	Returns the height of the rectangle.
			///
			/// \author	khaos
			/// \date	09.12.2009
			///
			/// \return	The rectangles height.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			T height() const;

			////////////////////////////////////////////////////////////////////////////////////////////////////
			/// \fn	T centerX() const
			///
			/// \brief	Returns the center position in x direction.
			///
			/// \author	khaos
			/// \date	09.12.2009
			///
			/// \return	The center x position.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			T centerX() const;

			////////////////////////////////////////////////////////////////////////////////////////////////////
			/// \fn	T centerY() const
			///
			/// \brief	Returns the center position in y direction.
			///
			/// \author	khaos
			/// \date	09.12.2009
			///
			/// \return	The center y position.
			////////////////////////////////////////////////////////////////////////////////////////////////////
			T centerY() const;



			
			T m_left;
			T m_top;
			T m_right;
			T m_bottom;

		protected:


		private:

	};





	///
	template<class T>
	inline rectangle<T>::rectangle()
	{

	}


	///
	template<class T>
	inline rectangle<T>::rectangle(T l, T t, T r, T b):
	m_left(l),
		m_top(t),
		m_right(r),
		m_bottom(b)
	{

	}





	///
	template<class T>
	inline void rectangle<T>::set(T l, T t, T r, T b)
	{
		this->m_left	= l;
		this->m_top		= t;
		this->m_right	= r;
		this->m_bottom	= b;
	}


	///
	template<class T>
	T rectangle<T>::width() const 
	{
		return T(this->m_right - this->m_left);
	}


	///
	template<class T>
	T rectangle<T>::height() const 
	{
		return T(this->m_bottom - this->m_top);
	}


	///
	template<class T>
	T rectangle<T>::centerX() const 
	{
		return T((this->m_right - this->m_left)*0.5f);
	}


	///
	template<class T>
	T rectangle<T>::centerY() const 
	{
		return T((this->m_bottom - this->m_top)*0.5f);
	}

}

#endif // rectangle_h__